<template>
    <div class="con">
        <div class="title">
            <p>{{realName}}{{mobilestr}}</p>
        </div>
        <div class="info">
            <dl>
                <dt class="fl">序列号</dt>
                <dd class="fr"><input type="text" v-model="number"></dd>
            </dl>
            <dl>
                <dt class="fl">Apple ID</dt>
                <dd class="fr"><input type="text" v-model="appleId"></dd>
            </dl>
            <dl>
                <dt class="fl">Password</dt>
                <dd class="fr"><input type="password" v-model="pwd"></dd>
            </dl>
            <dl>
                <dt class="fl">邮寄地址</dt>
                <dd class="fr">
                    <textarea name="" id="" cols="30" rows="10" v-model="address"></textarea>
                </dd>
            </dl>
        </div>
        <div class="btn" @click="ok()">
            提交
        </div>

    </div>
</template>

<script>
export default {
    name: "index",
    data() {
        return {
            number: "",
            appleId: "",
            pwd: "",
            address: "",
            realName:"",
            mobile:"",
            mobilestr:""
        };
    },
    methods: {
        ok() {
            if (this.number == "") {
                this.$toast("序列号不能为空");
            } else if (this.id == "") {
                this.$toast("appId不能为空");
            } else if (this.pwd == "") {
                this.$toast("密码不能为空");
            } else if (this.address == "") {
                this.$toast("邮寄地址不能为空");
            } else {
                var timestamp = Date.parse(new Date()) + 100;
                this.axios({
                    method: "post",
                    url: `${
                        this.siteUrl
                    }/h5/item/add.do?appid=web.2018&format=json&version=1.0&timestamp=${timestamp}`,

                    data: {
                        realName: this.realName,
                        mobile: this.mobile,
                        serialNo: this.number,
                        appleId: this.appleId,
                        passwd: this.pwd,
                        mailAddress: this.address
                    }
                })
                    .then(response => {
                     
                        if (response.data.success == 1) {
                             this.number="";
                            this.appleId="";
                            this.pwd="";
                            this.address=""
                            this.$toast(response.data.message);
                           
                        } else {
                            this.$toast(response.data.message);
                        }
                    })
                    .catch(function(error) {
                        console.log(error);
                    });
            }
        }

       
    },
    mounted() {
        this.realName = this.$route.query.realName;
        this.mobile = this.$route.query.mobile;

        this.mobilestr=this.mobile.substr(0, 3) + '****' + this.mobile.substr(7, 11);
        this.$toast.setDefaultOptions({
            duration: "800"
        });
    }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.con {
    width: 100%;
    min-height: 100vh;
    background: #199ed8;
}

.title {
    margin-top: 50px;
}
.title p {
    font-size: 18px;
    text-align: center;
    color: #fff;
}
.info {
    width: 80%;
    margin-left: 10%;
    margin-top: 50px;
}
dl {
    margin-top: 10px;
    overflow: hidden;
}
dl dt {
    width: 25%;
    color: #fff;
    line-height: 30px;
}
dl dd {
    width: 75%;
}
dl dd input {
    height: 30px;
    border-radius: 4px;
    width: 100%;
}
.btn {
    background: #0b94de;
    width: 80%;
    height: 44px;
    line-height: 44px;
    text-align: center;
    color: #fff;
    font-size: 18px;
    background: transparent;
    border: 1px solid #fff;
    border-radius: 4px;
    margin-left: 10%;
    margin-top: 20px;
}
textarea{
    border:none;
    width: 100%
}
</style>
